package org.wms.config;

import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.wms.store.MongoChatMemoryStore;

/**
 * @author : 阿盛哟
 * @description :配置ChatMemoryProvider
 * @createDate : 2025/4/30 8:44
 */
@Configuration
public class SeparateChatAssistantConfig {
    @Autowired
    private MongoChatMemoryStore  mongoChatMemoryStore;//注入mongoChatMemoryStore
    @Bean
    ChatMemoryProvider chatMemoryProvider() {
        return memoryId -> MessageWindowChatMemory.builder()
                .id(memoryId)
                .maxMessages(10)
                //.chatMemoryStore(new InMemoryChatMemoryStore())//存储聊天记录
                .chatMemoryStore(mongoChatMemoryStore) //配置存储聊天记录的方式
                .build();
    }
}